package cn.johnyu.consumer;

import cn.johnyu.commons.Greeter;
import org.apache.dubbo.config.ReferenceConfig;
import org.apache.dubbo.config.RegistryConfig;
import org.apache.dubbo.config.bootstrap.DubboBootstrap;

public class ConsumerApp {
    public static void main(String[] args) throws Exception{
        ReferenceConfig<Greeter> config = new ReferenceConfig<>();
        config.setInterface(Greeter.class);
//        config.setUrl("dubbo://localhost:20880");
        DubboBootstrap.getInstance()
                .application("consumer")
                .registry(new RegistryConfig("nacos://localhost:8848"))
                .reference(config)
                .start();

        Greeter greeter = config.get();
        for (int i = 0; i < 5; i++) {
            System.out.println(greeter.sayHello("john").getId());
        }
        System.in.read();
    }
}
